import { RouteRecordRaw } from "vue-router";
import HomeView from "@/views/HomeView.vue";
import NoAuthView from "@/views/NoAuthView.vue";
import ACCESS_ENUMS from "@/access/accessEnums";
import userLayoutView from "@/layouts/UserLayoutView.vue";
import loginView from "@/views/user/LoginView.vue";
import registerView from "@/views/user/RegisterView.vue";
import AddQuestionView from "@/views/question/AddQuestionView.vue";

const routes: Array<RouteRecordRaw> = [
  {
    path: "/user",
    name: "用户",
    component: userLayoutView,
    children: [
      {
        path: "login",
        name: "登录",
        component: loginView,
      },
      {
        path: "register",
        name: "注册",
        component: registerView,
      },
    ],
    meta: {
      hiddenInMenu: true,
    },
  },
  {
    path: "/",
    name: "在线刷题",
    component: HomeView,
    meta: {
      access: ACCESS_ENUMS.USER,
    },
  },
  {
    path: "/add/question",
    name: "创建题目",
    component: AddQuestionView,
    meta: {
      access: ACCESS_ENUMS.USER,
    },
  },
  {
    path: "/admin",
    name: "管理员管理",
    component: HomeView,
    meta: {
      access: ACCESS_ENUMS.ADMIN,
    },
  },
  {
    path: "/hidden",
    name: "隐藏菜单",
    component: HomeView,
    meta: {
      hiddenInMenu: true,
    },
  },
  {
    path: "/noLogin",
    name: "未登录",
    component: NoAuthView,
    meta: {
      access: "noLogin",
    },
  },
  {
    path: "/about",
    name: "关于我们",
    component: () => import("../views/AboutView.vue"),
  },
];

export default routes;
